var HtmlGenerator = function(){
	this.div = function(classes){
		var div = $( document.createElement("div") );
		div.addClass( classes );
		return div;
	};
	
	this.span = function(classes, text){
		var span = $(document.createElement("div") );
		span.addClass( classes );
		span.html( text );
		return span;		
	};
	
	this.input = function( type, classes, name, value ){
		var input = $( document.createElement("input") );
		input.prop('type', type);
		input.addClass( classes );
		input.prop('name', name);
		if( typeof( value ) != 'undefined' ){
			input.val( value );
		}
		return input;
	};
	
	this.fieldset = function( title ){
		var fieldset = $( document.createElement("fieldset") );
		var legend = $( document.createElement('legend') );
		legend.text( title );
		fieldset.append( legend );
		return fieldset;
	};
		
	
	this.label = function( text, classes ){
		var label = $( document.createElement('label') );
		label.addClass( classes );
		label.text( text );
		return label;
	};
	
	this.select = function( options, classes ){
		var select = $( document.createElement('select') );
		select.addClass( classes );
		
		for( var i in options ){
			select.append( $( document.createElement('option') ).text( options[i].name ).prop('value', options[i].value ) );
		}
		
		return select;
	};
	
	this.button = function( text ){
		var button = $( document.createElement('button') );
		button.text( text );
		return button;
	};
	
	this.table = function(){
		var that = this;
		var table = $( document.createElement('table') );
		var thead = $( document.createElement('thead') );		
		var tr = $( document.createElement('tr') );
		if( typeof( arguments ) != 'undefined' ){
			for( var i in arguments ){
				tr.append( that.th( arguments[i] ) );
			}
		}
		thead.append( tr );
		var tbody = $( document.createElement('tbody') );
		table.append( thead );
		table.append( tbody );
		return table;		
	};		
	
	this.tr = function(){
		var that = this;
		var tr = $( document.createElement('tr') );
		if( typeof( arguments ) != 'undefined' ){
			for( var i in arguments ){
				tr.append( that.td( arguments[i] ) );
			} 
		}
		return tr;
	};
	
	this.td = function( text ){
		var td = $( document.createElement('td') );
		td.html( text );
		return td;
	};
	
	this.th = function( text ){
		var th = $( document.createElement('th') );
		th.html( text );
		return th;
	};
	
	this.h4 = function( text ){
		var h4 = $( document.createElement('h4') );
		h4.html( text );
		return h4;
	};
};